#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#include "uthash.h"

int compare_ints(const void* a, const void* b);
int findContentChildren(int* g, int gSize, int* s, int sSize);

int main()
{
	return 0;
}

int findContentChildren(int* children, int size_children, int* cookies, int size_cookies)
{
	qsort(children, size_children, sizeof(int), compare_ints);
	qsort(cookies, size_cookies, sizeof(int), compare_ints);

	int res = 0;
	for (int i = 0, j = 0; i < size_children && j < size_cookies; i++, j++) {
		while (j < size_cookies && children[i] > cookies[j]) j++;
		if (j < size_cookies) res++;
	}
	return res;
}

int compare_ints(const void* a, const void* b)
{
	int arg1 = *(const int*)a;
	int arg2 = *(const int*)b;

	return (arg1 > arg2) - (arg1 < arg2); // 可行的简写
}
